package me.helllp.dake.generator.meta.core;

import java.util.Collections;
import java.util.Map;
import java.util.Optional;

import com.squareup.javapoet.AnnotationSpec;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class SmartAnnotation {
	private SmartType type;
	
	private Map<String, String> values;

	public SmartAnnotation() {}

	public SmartAnnotation(SmartType type, Map<String, String> values) {
		this.type = type;
		this.values = values;
	}

	public AnnotationSpec.Builder builder() {
		AnnotationSpec.Builder builder = AnnotationSpec.builder(type.makeClassName());
		Optional.ofNullable(values).orElse(Collections.emptyMap()).entrySet().stream().forEach(entry -> {
			builder.addMember(entry.getKey(),  "$S", entry.getValue());
		});
		return builder;
	}
}
